﻿<div class="panel panel-default">
    <div class="panel-heading">
        <h2 ng-if="!vm.isEditMode"> {{::vm.translate.get('Create News Item')}} </h2>
        <h2 ng-if="vm.isEditMode"> {{::vm.translate.get('Edit News Item')}} </h2>
    </div>
    <div class="panel-body">
        <form name="pageForm" class="form-horizontal">
            <div class="col-sm-offset-2 bg-danger" ng-show="vm.validationErrors">
                <ul>
                    <li ng-repeat="error in vm.validationErrors">{{error}}</li>
                </ul>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('News Item Name')}} </label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.newsItem.name" ng-change="vm.updateSlug()" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Slug')}} </label>
                <div class="col-sm-10">
                    <input name="slug" ng-model="vm.newsItem.slug" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Meta Title')}}</label>
                <div class="col-sm-10">
                    <input name="metaTitle" ng-model="vm.newsItem.metaTitle" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Meta Keywords')}}</label>
                <div class="col-sm-10">
                    <textarea name="metaKeywords" ng-model="vm.newsItem.metaKeywords" class="form-control" rows="2"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Meta Description')}}</label>
                <div class="col-sm-10">
                    <textarea name="metaDescription" ng-model="vm.newsItem.metaDescription" class="form-control" rows="3"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Thumbnail Image')}}</label>
                <div class="col-sm-10">
                    <input class="form-control" type="file" ngf-select ng-model="vm.newsItem.thumbnailImage" name="thumbnailImage" ngf-accept="'image/*'">
                    <img ngf-src="vm.newsItem.thumbnailImage" ngf-resize="{width: 200, height: 200, quality: 0.9}">
                    <img ng-show="!vm.thumbnailImage && vm.newsItem.thumbnailImageUrl" ng-src="{{vm.newsItem.thumbnailImageUrl}}" style="width: 200px; height: 200px" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Short Description')}} </label>
                <div class="col-sm-10">
                    <summernote editor="vm.shortDescEditor" ng-model="vm.newsItem.shortContent"></summernote>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Description')}}</label>
                <div class="col-sm-10">
                    <summernote on-image-upload="vm.imageUpload(files)" editor="vm.descEditor" ng-model="vm.newsItem.fullContent"></summernote>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" ng-model="vm.newsItem.isPublished"> {{::vm.translate.get('Is Published')}}
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Belong to categories</label>
                <div class="col-sm-10">
                    <div ng-repeat="newsCategory in vm.newsCategories">
                        <md-checkbox ng-checked="vm.newsItem.newsCategoryIds.indexOf(newsCategory.id) > -1" ng-click="vm.toggleNewsCategories(newsCategory.id)">
                            {{ newsCategory.name }}
                        </md-checkbox>
                    </div>
                </div>

            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button class="btn btn-primary" ng-click="vm.save()"><span class="glyphicon glyphicon-ok"></span> Save</button>
                    <button ui-sref="news-items" class="btn btn-default">Cancel</button>
                </div>
            </div>
        </form>
    </div>
</div>